// import { createBrowserRouter } from 'react-router-dom'
// import App from '../../App'
// import Home from '../home'
// import About from '../about'
// import Login from '../login'

import { lazy, Suspense } from "react"

import App from '../App'
const Home = lazy(() => import('../view/home'))
const About = lazy(() => import('../view/about'))
const Login = lazy(() => import('../view/login'))
const ErrorPage = lazy(() => import('../view/error'))
const Board = lazy(() => import('../view/board'))
const TablePage = lazy(() => import('../view/list'))

const lazyload = children => {
  return <Suspense fallback={<h1>loading...</h1>}>{children}</Suspense>
}

const routes = [
  {
    title: 'App',
    path: '/',
    element: <App />,
    children: [
      {
        title: '首页',
        path: 'home',
        element: lazyload(<Home />),
      },
      {
        title: '关于',
        path: 'about',
        element: lazyload(<About />),
      },
      {
        title: '看板',
        path: '/board',
        element: lazyload(<Board />),
      },
      {
        title: '列表',
        path: '/lists',
        element: lazyload(<TablePage />),
      },
    ]
  },
  {
    title: '登录',
    path: '/login',
    element: lazyload(<Login />),
  },
  {
    title: '404',
    path: '*',
    element: lazyload(<ErrorPage />),
  }
]

// const router = createBrowserRouter(routers);

export default routes;